<script type="text/javascript">
$(document).ready(function () {
	var flagDwo = true;
	var flagEmail = true;
	$("input[name=dwo]:text").blur( function() {
		var val = $(this).val();
		var url = "{$websiteURL}/controller/checkExistDWO.php?dwo=" + val; 
		$.ajax({
			type: "GET",
	  		url: url 
		}).done(function( msg ) {
				if(msg == true)
				{
					$('#resultCheck').show();
					$('#resultCheck').html("DWO Already Taken");
					flagDwo = false;
				}
				else
				{
					$('#resultCheck').hide();
					flagDwo = true;
				}
			});	
	});
	
	$("input[name=email]:text").blur( function() {
		var val = $(this).val();
		var url = "{$websiteURL}/controller/checkExistEmail.php?email=" + val; 
		$.ajax({
			type: "GET",
	  		url: url 
		}).done(function( msg ) {
				if(msg == true)
				{
					$('#resultCheckEmail').show();
					$('#resultCheckEmail').html("Email Already Taken");
					flagEmail = false;
				}
				else
				{
					$('#resultCheckEmail').hide();
					flagEmail = true;
				}
			});	
	});
	
	$('#mws-validate').submit(function() {
		if(flagEmail == true && flagDwo == true)
			return true;
		else
			return false;
		
	});
});
</script>
<div class="mws-panel grid_7">
                	<div class="mws-panel-header">
                    	<span class="mws-i-24 i-list">Create New Schedule</span>
                    </div>
                    <div class="mws-panel-body">
                    	<form class="mws-form" method="POST" action="index.php?type=schedule&action=add" id="mws-validate" >
                    		<div class="mws-form-inline">
                    			<div class="mws-form-row">
                    				
                    				<div class="mws-form-item clearfix">
                    					<ul class="mws-form-list">
                    						<li><input type="radio" name="chooseClient" value="0" /> <label>Choose Exsit Client</label></li>
                    						<li><input type="radio" name="chooseClient" value="1" checked="checked" /> <label>New Client</label></li>                   						
                    					</ul>
                    				</div>
                    			</div>
                    			<div id="exsitClient" style="display: none;">
                    				<div class="mws-form-row">
	                    				<label>Client Name</label>
	                    				<div class="mws-form-item medium">
	                    					<input id="clientText" type="text" class="mws-textinput required" name="exsitClientName" readonly="readonly"/>
	                    					<input type="hidden" id="clientValue" name="client" class="required" />
	                    				</div>
	                    				<div style="margin-top: 10px;">
												<button type="button" class="mws-button green" name="btn_client" onclick="listClient()" ><span></span>Choose Client</button>
										</div>
	                    			</div>                  				
                    				<input type="hidden" name="dwoNumber" >
                    			</div>
                    			<div id="newClient">
	                    			<div class="mws-form-row">
	                    				<label>D/O or W/O Number</label>
	                    				<div class="mws-form-item medium">
	                    					<input type="text" class="mws-textinput required" name="dwo" /><div style=" display:none; color:white; margin-top: 10px; background: red ; padding: 10px; width: 300px;"  id="resultCheck" ></div>
	                    				</div>
	                    			</div>
	                    			<div class="mws-form-row">
	                    				<label>Project In Charge</label>
	                    				<div class="mws-form-item medium">
	                    					<input type="text" class="mws-textinput required" name="PIC" />
	                    				</div>
	                    			</div>
	                    			<div class="mws-form-row">
	                    				<label>Client's Company</label>
	                    				<div class="mws-form-item medium">
	                    					<input type="text" class="mws-textinput required" name="clientCompany" />
	                    				</div>
	                    			</div>
	                    			<div class="mws-form-row">
	                    				<label>Client Name</label>
	                    				<div class="mws-form-item medium">
	                    					<input type="text" class="mws-textinput required" name="clientName" />
	                    				</div>
	                    			</div>
	                    			<div class="mws-form-row">
	                    				<label>Client Contact</label>
	                    				<div class="mws-form-item medium">
	                    					<input type="text" class="mws-textinput required" name="clientContact" />
	                    				</div>
	                    			</div>
	                    			<div class="mws-form-row">
	                    				<label>Venue/ Location</label>
	                    				<div class="mws-form-item medium">
	                    					<input type="text" class="mws-textinput required" name="location" />
	                    				</div>
	                    			</div>
	                    			<div class="mws-form-row">
	                    				<label>Email</label>
	                    				<div class="mws-form-item medium">
	                    					<input type="text" class="mws-textinput required" name="email" /><div style=" display:none; color:white; margin-top: 10px; background: red ; padding: 10px; width: 300px;"  id="resultCheckEmail" ></div>
	                    				</div>
	                    			</div>
                    			</div>
                    			<div class="mws-form-row">
                                    <label>Delivery Date</label>
                                    <div class="mws-form-item small">
                                    	<input type="text" class="mws-textinput required mws-datepicker" name="deliveryDate" readonly="readonly" value="{$date}"/>
                                    </div>
                                </div>                              
                                <div class="mws-form-row">
                                    <label>Delivery Time</label>
                                    <div class="mws-form-item small">
                                    	<input class="mws-textinput required" type="text" id="timepicker"  readonly="readonly" name="deliveryTime" value="{$tool->convert24hTo12h($time)}" />
                                    </div>                            
                                </div>
                                <div class="mws-form-row">
                                    <label>Collection Date</label>
                                    <div class="mws-form-item small">
                                    	<input type="text" class="mws-textinput required mws-datepicker" name="collectionDate" readonly="readonly"/>
                                    </div>
                                </div>                              
                                <div class="mws-form-row">
                                    <label>Collection Time</label>
                                    <div class="mws-form-item small">
                                    	<input class="mws-textinput required" type="text" id="timepicker2"  readonly="readonly" name="collectionTime" />
                                    </div>
                                </div>
                                <div class="mws-form-row">
                    				<label>Transport / Driver</label>
                    				<div class="mws-form-item small">
                    					<input type="text" class="mws-textinput required" name="transportDriver" />
                    				</div>
                    			</div>
                    			<div class="mws-form-row">
                    				<label>Job Descriptions / Special Instruction</label>
                    				<div class="mws-form-item large">
                    					<textarea rows="100%" cols="100%" name="jobDescription" class="required"></textarea>
                    				</div>
                    			</div>
                    			
                    		</div>
                    		<div class="mws-button-row">
                    			<input type="submit" value="Create Schedule" class="mws-button green" />
                    		</div>
                    	</form>
                    </div>    	
                </div>